window.addEvent('domready',function(){
	var status = {
			'true': '-',
			'false': '+'
		};
	var status2 = {
		'true': 'Create Counter',
		'false': ''
	}
	APP.slide = {};
	APP.slide.perbuatanView = new Fx.Slide('perbuatanView');
	APP.slide.perbuatanView.addEvent('complete', function() {
		$('perbuatanView_icon').set('html', status[APP.slide.perbuatanView.open]);
	});
	
	APP.slide.notificationView = new Fx.Slide('notificationView');
	APP.slide.notificationView.addEvent('complete', function() {
		$('notificationView_icon').set('html', status[APP.slide.notificationView.open]);
	});
	
	APP.slide.counterView = new Fx.Slide('counterView');
	APP.slide.counterView.addEvent('complete', function() {
		$('notificationView_icon').set('html', status[APP.slide.counterView.open]);
	});
	
	if ($chk($('counterOuterView'))){
		APP.slide.counterOuterView = new Fx.Slide('counterOuterView').hide();
		APP.slide.counterOuterView.addEvent('complete', function() {
			$('btGroup2').setStyle('display',APP.slide.counterOuterView.open?'block':'none');
			$('btGroup1').setStyle('display',APP.slide.counterOuterView.open?'none':'block');
		});
	
		$$('.RTE').mooEditable({
			actions: "bold italic underline strikethrough | formatBlock justifyleft justifyright justifycenter justifyfull | " +
					"insertunorderedlist insertorderedlist indent outdent | undo redo | createlink unlink | " +
					"urlimage | toggleview",
			dimensions:{x:'100%', y:'300px'}
		});
		
		//formcheck untuk counter
		APP.formCheck = new FormCheck($('counterOuterView').getElement('form'),{submitByAjax:true, 
	        onAjaxSuccess: function(res){
				var json = JSON.decode(res);
				if (json.error)	FBModal_message(APP.base+'/ajax/messageDialog', "Save", json.msg);
				else location.replace(json.url);
				this.onValidateFailure();
	        },
	        onValidateFailure: function(){
	        	var bt = $('btGroup2').getElement('input');
	        	bt[0].disabled=false;
	        }
	    });
	}	
});

function showImage(title, imageTitle, imageUrl){
	FBModal_show2(APP.utils+'/imageViewer', 'post', 
		"title="+title+
		"&imageTitle="+imageTitle+
		"&imageUrl="+imageUrl+
		"&maxWidth="+(screen.width-50)+
		"&maxHeight="+(screen.height-50), true, false, null, {
		onSuccess: function(res){}
		});
}